/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package classPack;

import org.jasypt.util.text.BasicTextEncryptor;

/**
 *
 * @author Eu
 */
public class Encrypt {

    private static Encrypt secao = null;
    private BasicTextEncryptor textEncryptor = null;

    private Encrypt() {
    }

    public static Encrypt getInstance() {
        if (secao == null) {
            secao = new Encrypt();
        }
        return secao;
    }

    public String getEncryptMsg(String message, String chave) {
        String saida = "";
        textEncryptor = new BasicTextEncryptor();
        textEncryptor.setPassword(chave);
        saida = textEncryptor.encrypt(message);
        return saida;
    }

    public String getDecryptMsg(String message, String chave) {
        String saida = "";
        textEncryptor = new BasicTextEncryptor();
        textEncryptor.setPassword(chave);
        saida = textEncryptor.decrypt(message);
        return saida;
    }
}
